﻿using StorageApi.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace StorageApi.Controllers
{
    public class AdminController : Controller
    {
        // GET: Admin
        JooWMSEntities db = new JooWMSEntities();
        // GET: Admin
        public ActionResult Index()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Index(Admin admin)
        {
            var user = db.Admin.Where(a => a.UserName == admin.UserName && a.PassWord == admin.PassWord).FirstOrDefault();
            if (user == null)
            {
                return Content("<script>alert('账号或密码错误！');window.location='/admin/index'</script>");
            }
            Session["user"] = user;
            return Redirect("/Home/Index");
        }
    }
}